package com.jgdt.jgdtkasannong_university_gene_backend.service.base.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jgdt.jgdtkasannong_university_gene_backend.entity.base.BaseRegion;
import com.jgdt.jgdtkasannong_university_gene_backend.mapper.base.BaseRegionMapper;
import com.jgdt.jgdtkasannong_university_gene_backend.service.base.BaseRegionService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 基地_地区表 服务实现类
 * </p>
 *
 * @author chenzg
 * @since 2025-05-06
 */
@Service
public class BaseRegionServiceImpl extends ServiceImpl<BaseRegionMapper, BaseRegion> implements BaseRegionService {

    @Override
    public List<BaseRegion> getBaseRegionBy(BaseRegion region) {
        if(ObjectUtils.isEmpty(region)){
            return new ArrayList<>();
        }
        LambdaQueryWrapper<BaseRegion> queryWrapper=new LambdaQueryWrapper<>();
        if(region.getMenuId()!=null){
            queryWrapper.eq(BaseRegion::getMenuId,region.getMenuId());
        }
        return list(queryWrapper);
    }
}
